<?php

namespace app\common\model\merchant;

use think\Model;
use traits\model\SoftDelete;

class MerchantShop extends Model
{

    use SoftDelete;


    // 表名
    protected $name = 'merchant_shop';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';


    protected $hidden = [
        'location',    //geo经纬度   X(location) => lng, Y(location) => lat
        'deletetime',
    ];

    const STATUS_DISABLED = '0'; // 禁用
    const STATUS_ENABLED = '1'; // 启用


    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }

    public function getCitypickerAttr($value, $data)
    {
        return implode('/', [$data['province'], $data['city'], $data['district']]);
    }

    public function merchant()
    {
        return $this->belongsTo(Merchant::class, 'merchant_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
